function getTime (time) { //返回年月日
	if(typeof(time) != 'number' &&  time.indexOf(':') == -1) {
		time = time * 1
	}
	let dates = new Date(time)
	let year = dates.getFullYear()
	let month = dates.getMonth() == 0 ? '01' : dates.getMonth() + 1 < 10 ?  '0' + (dates.getMonth() + 1) : dates.getMonth() + 1
	let day = dates.getDate() < 10 ? '0' + dates.getDate() : dates.getDate()

	return year + '-' + month + '-' + day
}

function getHms (date) {
	if(date.indexOf(':') == -1) {
		date = date * 1
	}
	let dates = new Date(date)
	let hours = dates.getHours() < 10? '0' + dates.getHours() : dates.getHours()
	let minutes = dates.getMinutes() < 10? '0' + dates.getMinutes() : dates.getMinutes()
	
	return ' ' + hours + ':' + minutes
}

function getGapTime (nextTime, nowTime) { //返回相差天时分
	if(typeof(nextTime) !== 'number') {
		nextTime = Date.parse(nextTime)
	}
	if(typeof(nowTime) !== 'number') {
		nowTime = Date.parse(nowTime)
	}
		let ti = nextTime - nowTime
		let day = Math.floor(ti / (1000 * 3600 * 24))
		let hour = Math.floor(ti % (1000 * 3600 * 24) / (1000 * 3600))
		let minute = Math.floor(ti % (1000 * 3600) / 1000 / 60)
		
		return [day, hour, minute]
}

let gets = new Object()
gets.getTime = getTime
gets.getGapTime = getGapTime
gets.getHms = getHms

module.exports.getTime = gets